package cn.bugstack.chatgpt.data.config;

import cn.bugstack.deepseek.executor.model.deepseek.config.DeepSeekConfig;
import cn.bugstack.deepseek.session.OpenAiSession;
import cn.bugstack.deepseek.session.OpenAiSessionFactory;
import cn.bugstack.deepseek.session.defaults.DefaultOpenAiSessionFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(DeepSeekSDKConfigProperties.class)
public class DeepSeekSDKConfig {

    @Bean(name = "deepSeekOpenAiSession")
    @ConditionalOnProperty(value = "deepseek.sdk.config.enabled", havingValue = "true", matchIfMissing = false)
    public OpenAiSession openAiSession(DeepSeekSDKConfigProperties properties){

        DeepSeekConfig deepSeekConfig = new DeepSeekConfig();
        deepSeekConfig.setApiHost("https://api.deepseek.com/");
        deepSeekConfig.setApiKey("sk-3d267048d00a40e58a314132c2e10d76");

        cn.bugstack.deepseek.session.Configuration configuration = new cn.bugstack.deepseek.session.Configuration();
        configuration.setDeepSeekConfig(deepSeekConfig);
        OpenAiSessionFactory factory = new DefaultOpenAiSessionFactory(configuration);

        return factory.openSession();
    }
}
